<?php
class Controller_Admin_Preview extends Controller_Template
{
	public function __construct ($request, $response)
	{
		parent::__construct($request, $response);
		$this->template = "smarty:admin/preview/index";
	}

	/*
	 * 预览 房产首页-html
	 */
	public function action_fangchan()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('fangchan',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.fangchan'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/fangchan');
	}

	/*
	 * 预览 家居首页-html
	 */
	public function action_jiaju()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('jiaju',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.jiaju'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/jiaju');
	}

	/*
	 * 预览 家居-地方-html
	 */
	public function action_jiaju_city()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('jiaju_city',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.jiaju_city'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/jiaju_city');
	}

	/**
	 * 首页弹窗广告预览 - html
	 */
	public function action_openwindow()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('openwindow',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.openwindow'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/openwindow');
	}

	/**
	 * 新闻内页右侧推广位 预览 - html
	 */
	public function action_news_right_list()
	{
		$content = $this->request->post('fck_html');
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/news_right_list');
	}

	/**
	 *  新闻内页下部推广位 预览 - html
	 */
	public function action_news_bottom_list()
	{
		$content = $this->request->post('fck_html');
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/news_bottom_list');
	}


	/*
	 * 预览 新闻最终页-html
	 */
	public function action_news()
	{
		$this->template->set('content',$this->request->post('fck_html'));
		$this->template->set_filename('smarty:admin/preview/news');
	}

	/*
	 * 预览 新闻最终页-html
	 */
	public function action_news_home()
	{
		$this->template->set('content',$this->request->post('fck_html'));
		$this->template->set_filename('smarty:admin/preview/news_home');
	}

	/*
	 * 预览 E购房首页-html
	 */
	public function action_egou()
	{
		//2011-10-11 修改成获取房产的内容，调用egou的模板，不同css
		//$this->template->set('content',$this->request->post('fck_html'));
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('fangchan',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.egou'),$content);
		$this->template->set('content',$content);

		$this->template->set_filename('smarty:admin/preview/egou');
	}

	/*
	 * 预览 二手房页面推广位 - html
	 */
	public function action_ershoufang()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('ershoufang',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.ershoufang'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/ershoufang');
	}

	/*
	 * 预览 家居组图页面推广位 - html
	 */
	public function action_jiajuzutu()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('jiajuzutu',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.jiajuzutu'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/jiajuzutu');
	}

	/*
	 * 预览 楼盘详情推广位 - html
	 */
	public function action_loupanxiangqing()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('loupanxiangqing',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.loupanxiangqing'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/loupanxiangqing');
	}

	/*
	 * 预览 装修日记推广位 - html
	 */
	public function action_zhuangxiuriji()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('zhuangxiuriji',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.zhuangxiuriji'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/zhuangxiuriji');
	}

	/**
	 * 预览 狐首推广位 - html
	 */
	public function action_sohuindex()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('sohuindex',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.sohuindex'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/sohuindex');
	}

	/**
	 * 预览 新搜狐家居首页jiaju_new - html
	 */
	public function action_jiaju_new()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('jiaju_new',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.jiaju_new'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/jiaju_new');
	}


	/**
	 * 预览 新搜狐家居首页jiaju_new - html
	 */
	public function action_jiaju_image()
	{
		$content = $this->request->post('fck_html');
		$content = Cooperate::get_content_html('jiaju_image',$content);
		$content = str_replace(Kohana::config('home.link_replace_value'),Kohana::config('home.cooperate_pid.jiaju_image'),$content);
		$this->template->set('content',$content);
		$this->template->set_filename('smarty:admin/preview/jiaju_image');
	}



	/*
	 * 预览 新闻内页右侧单品广告位-html
	 */
	public function action_onegoods_recommend()
	{
		$data = array();
		$goods['goods_id']  = intval(trim($this->request->post('goods_id')));
		$goods['url']       = strval(trim($this->request->post('url')));
		$goods['title'] = strval(trim($this->request->post('title')));
		$goods['price'] = floatval(trim($this->request->post('price')));
		$goods['promote_price'] = floatval(trim($this->request->post('promote_price')));
		$goods['cover_thumb']   = strval(trim($this->request->post('cover_thumb')));
		$goods_json_str = json_encode($goods);
        $goods_obj = json_decode($goods_json_str);
        $data = Cooperate::onegoods_recommend($goods_obj);
		$this->template->set('goods_info',$data);
		$this->template->set_filename('smarty:admin/preview/onegoods_recommend');
	}


}
